#ifndef LOCALIMAGEVIEW_H
#define LOCALIMAGEVIEW_H

#include <QThread>
#include <QTimer>
#include <QMutex>
#include "imageview.h"

#include <pthread.h>
#include <queue>
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

class LocalImageView : public ImageView
{
    Q_OBJECT
public:
    explicit LocalImageView(QWidget *parent = 0);
    
signals:

public slots:
    void changeVideoSource(QString m_source);
    void continueGrab();
    void stopGrab();
    void grab();
    void setSaveState(int s);

public:
    QString m_source;
    int m_device;
    QTimer m_timer;
    cv::Mat m_image;
    cv::VideoCapture m_capture;
    bool m_last_timer_state;//for pause and continue;
    QMutex m_img_mutex;

    QString m_save_folder;
    QString m_save_file;
    cv::VideoWriter m_save_writer;
    bool m_save_state;
    QMutex m_save_mutex;


private:
    void saveImg2Video(cv::Mat img);
    void startSaveVideo();
    void stopSaveVideo();
};



#endif // LOCALIMAGEVIEW_H
